<?php

/**
 * Created by PhpStorm.
 * User: WhiteBlue
 * Date: 15/3/2
 * Time: 下午3:54
 */
class indexController extends Controller
{

    public function index()
    {
        $title = site::where('key', '=', 'title')->firstOrFail();
        $content = site::where('key', '=', 'content')->firstOrFail();
        $this->view = view::make('index')->with('title', $title->value)->with('content', $content->value);
    }

    public function newContent()
    {
        if ($this->getMethod() == 'POST') {
            $var = $this->getParam('content', '');
            if (($var != '') && (strlen($var) < 200)) {
                $content = new content;
                $content->content = $var;
                $content->time = new DateTime();
                $content->save();
            }
        }
        $this->redirect('');
    }

}

